﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using static WenSkin.Controls.WenListBoxControl;

namespace WenSkin.Design.Designer
{
    public class WenListBoxControlDesigner : TextDesigner
    {
        public override void AddDesignerActionList()
        {
            this.ActionLists.Add(new WenDesignerActionList(this.Component));
        }

        public class WenDesignerActionList : TextBoxDesignerActionList
        {
            public WenDesignerActionList(IComponent component) : base(component)
            {
            }

            [Editor(typeof(Design.Editor.WenCollectionEditor), typeof(UITypeEditor))]
            public WenListBoxControlItemCollection Items
            {
                get => TypeDescriptor.GetProperties(this.Component)["Items"].GetValue(this.Component) as WenListBoxControlItemCollection;
                set => TypeDescriptor.GetProperties(this.Component)["Items"].SetValue(this.Component, value);
            }
            public string ColumnName
            {
                get => TypeDescriptor.GetProperties(this.Component)["ColumnName"].GetValue(this.Component)?.ToString();
                set => TypeDescriptor.GetProperties(this.Component)["ColumnName"].SetValue(this.Component, value);
            }
            public int ItemHight
            {
                get => (int)TypeDescriptor.GetProperties(this.Component)["ItemHight"].GetValue(this.Component);
                set => TypeDescriptor.GetProperties(this.Component)["ItemHight"].SetValue(this.Component, value);
            }
            public bool AutoItemHight
            {
                get => (bool)TypeDescriptor.GetProperties(this.Component)["AutoItemHight"].GetValue(this.Component);
                set => TypeDescriptor.GetProperties(this.Component)["AutoItemHight"].SetValue(this.Component, value);
            }
            public Image ButtonImage
            {
                get => (Image)TypeDescriptor.GetProperties(this.Component)["ButtonImage"].GetValue(this.Component);
                set => TypeDescriptor.GetProperties(this.Component)["ButtonImage"].SetValue(this.Component, value);
            }
            public bool RemoveButtonShow
            {
                get => (bool)TypeDescriptor.GetProperties(this.Component)["RemoveButtonShow"].GetValue(this.Component);
                set => TypeDescriptor.GetProperties(this.Component)["RemoveButtonShow"].SetValue(this.Component, value);
            }
            public bool ButtonShow
            {
                get => (bool)TypeDescriptor.GetProperties(this.Component)["ButtonShow"].GetValue(this.Component);
                set => TypeDescriptor.GetProperties(this.Component)["ButtonShow"].SetValue(this.Component, value);
            }
            public override DesignerActionItemCollection GetSortedActionItems()
            {
                DesignerActionPropertyItem text = new DesignerActionPropertyItem("Text", "文本");
                DesignerActionPropertyItem item = new DesignerActionPropertyItem("Items", "集合编辑");
                DesignerActionPropertyItem columnName = new DesignerActionPropertyItem("ColumnName", "默认数据绑定列");
                DesignerActionPropertyItem itemHight = new DesignerActionPropertyItem("ItemHight", "单项高度");
                DesignerActionPropertyItem autoItemHight = new DesignerActionPropertyItem("AutoItemHight", "是否自动尺寸");
                DesignerActionPropertyItem buttonImage = new DesignerActionPropertyItem("ButtonImage", "自定义图标");
                DesignerActionPropertyItem buttonShow = new DesignerActionPropertyItem("ButtonShow", "是否显示自定义按钮");
                DesignerActionPropertyItem removeButtonShow = new DesignerActionPropertyItem("RemoveButtonShow", "是否显示删除按钮");

                return new DesignerActionItemCollection() { item, columnName, itemHight, autoItemHight, buttonImage, buttonShow, removeButtonShow };
            }
        }
    }
}
